package com.smh.hmdianping.vo;

/**
 * @author shiminghui
 * @date 2025/3/27 15:55
 * @description: TODO
 */
public class ResponseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(200, "success", data);
    }

    public static <T> ResponseResult<T> success(String msg, T data) {
        return new ResponseResult<>(200, msg, data);
    }

    public static <T> ResponseResult<T> success(String msg) {
        return new ResponseResult<>(200, msg, null);
    }

    public static <T> ResponseResult<T> fail(String msg) {
        return new ResponseResult<>(500, msg, null);
    }

    public static <T> ResponseResult<T> fail(String msg, T data) {
        return new ResponseResult<>(500, msg, data);
    }

    public static <T> ResponseResult<T> fail(Integer code, String msg) {
        return new ResponseResult<>(code, msg, null);
    }

    public static <T> ResponseResult<T> fail(Integer code, String msg, T data) {
        return new ResponseResult<>(code, msg, data);
    }
}
